<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%
	//查询住院收入
	String yydm =  input.getDesc("yydm","02");//医院代码
	String ksdm = input.getDesc("ksdm","-1"); //传入科室代码代表该科室主任
	String date = input.getDesc("start_date","2017-12-18");//开始时间
	String endDa = input.getDesc("end_date","2017-12-24");//结束时间

	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd");
	String nowDate = sdf2.format(sdf.parse(date));
	String nowEndDa = sdf2.format(sdf.parse(endDa));
	
	String startDate = nowDate+"00:00:00";
	String endDate = nowEndDa+"23:59:59";

	String sqlWhere = "  js.zxrq > '"+ startDate + "' and js.zxrq < '" + endDate+"' " ;
	if(!yydm.equals("-1"))
		sqlWhere += " and js.ksdm in (select new map (id as id) from his_dept where  yydm ='"+yydm+"') " ;
	if(!"-1".equals(ksdm)){
		sqlWhere += " and js.ksdm in( " + ksdm + ")";
	}
	//住院收入

	List<Map> feelist = QBuilder.db("basedb").queryHql("select new map( js.zje as zje ) from ZY_BRFYMXK js  where  " + sqlWhere+ " ");

	double money = 0;
	for(Map map : feelist ){
		double moneyTemp = Double.parseDouble(map.get("zje").toString());
		money += moneyTemp;
	}
	DecimalFormat df = new DecimalFormat("######0.000000"); 
	money = money/10000;
	Map<String,Object> ma = new HashMap<String,Object>();
	Map<String,Object> ma1 = new HashMap<String,Object>();
	ma.put("sumCount",df.format(money));
	ma1.put("data",ma);
	Message msg = new Message();

	msg.put("errcode",0);
	msg.put("zy_charge_count",ma1);

	out.println(msg);
%>